﻿using System;

namespace Listing1_84
{
    public class Program
    {
        static void Main()
        {
            Pub p = new Pub();
            p.OnChange += (sender, e)
            => Console.WriteLine("Event raised: {0}", e.Value);
            p.Raise();
            Console.ReadKey();
        }
    }

    public class MyArgs : EventArgs
    {
        public MyArgs(int value)
        {
            Value = value;
        }
        public int Value { get; set; }
    }

    public class Pub
    {
        public event EventHandler<MyArgs> OnChange = delegate { };
        public void Raise()
        {
            OnChange(this, new MyArgs(42));
        }
    }
}
